<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <h2>事件绑定</h2>
    <button @click="fn1('你好')">点击</button>
    <button @click="fn2($event)">事件对象</button>
    <button @click="fn3(666, $event)">参数+事件对象</button>
    <!-- 1.通过输入框修改p标签，input变化p也变 -->
    <!-- 2.通过data修改input标签，p也变 -->
    <p>
      v-model是由v-on:input和v-bind:value结合在一起的指令，监听输入框的input事件，更新数据，使得页面中的p标签页更新。value属性的值是一个变量，和p的内容一致。
    </p>
    <input type="text" @input="fn4($event)" :value="word">
    <p>{{word}}</p>
  </div>
  <script src="./vue.js"></script>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        msg: 'hello',
        word: ''
      },
      methods: {
        fn1(info) {
          alert(info);
        },
        fn2(e) {
          console.log(e);
        },
        fn3(num, e) {
          console.log(num);
          console.log(e);
        },
        fn4(e) {
          this.word = e.target.value;
        }
      },
    })
  </script>
</body>
</html>